package ui.juego

import org.uqbar.arena.layout.HorizontalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import ui.juego.utilidades.IconUtils

class VisitarLugarDialog extends Dialog<VisitarLugar> {
	
	new(WindowOwner owner, VisitarLugar model) {
		super(owner, model)
		title = '''Resolviendo: «modelObject.investigacion.caso.nombre»'''
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {}
	
	override createMainTemplate(Panel mainPanel) {
		val headPanel = new Panel(mainPanel) => [
			layout = new HorizontalLayout
		]
		new Label(headPanel) => [
			text = "Estás visitando:"
			fontSize = 12
		] 
		new Label(headPanel) => [
			bindValueToProperty("lugar.nombreTipoLugar")
			fontSize = 12
		]
		new Label(mainPanel) => [
			heigth = 20
		]
		new Label(mainPanel) => [
			bindValueToProperty("infoAMostrar")
		]
		new Label(mainPanel) => [
			heigth = 20
		]
		new Label(mainPanel) => [
			heigth = 20
		]
		
		new Button(mainPanel) => [
			caption = "Continuar"
			onClick[ |
				if(modelObject.puedeTerminarJuego) {
					close
					new JuegoTerminadoDialog(this, new JuegoTerminado(modelObject.investigacion, modelObject.lugar)).open
				}
				else close
			]
		]
	}
}